package com.catering.service.Impl;

import com.catering.domain.Customer;
import com.catering.domain.Vip;
import com.catering.mapper.CustomerMapper;
import com.catering.mapper.VipMapper;
import com.catering.service.VipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 作者:烟火味的男孩儿
 * 描述:一条寻找bug的道路
 * 时间:2024/10/18
 */
@Service
public class VipServiceImpl implements VipService {
    //注入vipservicemapper
    @Autowired
    private VipMapper vipMapper;
    @Autowired
    private CustomerMapper customerMapper;

    @Override
    public List<Customer> queryAllVips() {
        return customerMapper.queryMsgByVip();
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return vipMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKey(Customer customer) {
        return customerMapper.updateByPrimaryKeySelective(customer);
    }

//    @Override
//    public int updateByPrimaryKey(Vip vip) {
//        return vipMapper.updateByPrimaryKeySelective(vip);
//    }

    @Override
    public Customer getCustomerById(Long id) {
        return customerMapper.selectByPrimaryKey(id);
    }

    @Override
    public int getCustomerCount() {
        return vipMapper.queryCount();
    }

    @Override
    public int addCustomerToVip(Vip vip) {
        //添加客户信息
//        int row1 = customerMapper.insertSelective(customer);
//        Integer id = customer.getVipId();
//        int money = customer.getStorageMoney();
//        Vip vip = new Vip();
//        if (money > 0 && money < 2000) {
//            vip.setVtype(1);
//        } else if (money <= 5000) {
//            vip.setVtype(2);
//        } else if (money <= 10000) {
//            vip.setVtype(3);
//        } else {
//            vip.setVtype(4);
//        }
//        vip.setId(id);
//        vip.setVid(id);
        //添加会员信息
        return vipMapper.insertSelective(vip);
    }

    @Override
    public List<Customer> queryAllCustomers() {
        return customerMapper.queryAllCustomers();
    }

}
